package com.wanmait.baohan.service.Impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.baohan.mapper.PermissionsMapper;
import com.wanmait.baohan.pojo.Permissions;
import com.wanmait.baohan.service.PermissionsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * TODO
 *
 * @author 打豆豆
 * @version 1.0
 * @date 2021/1/7 16:13
 * @description:
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PermissionsServiceImpl implements PermissionsService {

    @Resource
    private PermissionsMapper permissionsMapper;

    @Override
    public Set<String> findAllPermissionsByStaffId(Integer id) {
        Set<String> permissions = new HashSet<>();
        Set<String> itemPermissions = permissionsMapper.selectAllPermissionsByStaffId(id);
        itemPermissions.forEach(s -> {
            if (s != null && !s.isEmpty()) {
                if (s.contains(",")) {
                    String[] split = s.split(",");
                    for (int i = 0; i < split.length; i++) {
                        permissions.add(split[i]);
                    }
                } else {
                    permissions.add(s);
                }
            }
        });

        return permissions;
    }

    @Override
    public void insert(Permissions object) {

    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    public void update(Permissions object) {

    }

    @Override
    public Permissions findById(Integer id) {
        return null;
    }

    @Override
    public List<Permissions> findAll() {
        return null;
    }

    @Override
    public List<Permissions> findAll(Permissions object) {
        return null;
    }

    @Override
    public PageInfo<Permissions> findPage(int pageNum) {
        return null;
    }

    @Override
    public PageInfo<Permissions> findPage() {
        return null;
    }

    @Override
    public PageInfo<Permissions> findPage(int pageNum, Permissions object) {
        return null;
    }

    @Override
    public PageInfo<Permissions> findPage(Permissions object) {
        return null;
    }
}
